package com.yoo.module_base.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding
import com.yoo.module_base.utils.StatusBarUtil

abstract class BaseCommonFragment<VB : ViewBinding, ViewModel : BaseViewModel>(val inflaterBlock: (LayoutInflater, ViewGroup?, Boolean) -> VB, private val modelClass: Class<ViewModel>) : BaseFragment() {
    var binding: VB? = null
    var mViewModel: ViewModel? = null

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = inflaterBlock(inflater, container, false)
        mViewModel = ViewModelProvider(requireActivity())[modelClass]
        onConCreateViewFrame()
//        binding?.root?.setPadding(0,StatusBarUtil.getStatusBarHeight(activity),0,0)
        return binding?.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
        initData()
        initListener()
    }

    open fun initView() {}
    open fun initListener() {}

    abstract fun onConCreateViewFrame()

    abstract fun initData()



}